import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Change {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入日期：");
        String s = in.next();
        SimpleDateFormat df=null;
        Date date = null;
        String[] sl ={"yyyy-MM-dd","yyyy/MM/dd","yyyyMMdd"};
        for(int i=0;i<3;i++){
        try {
            df=new SimpleDateFormat(sl[i]);
            date=df.parse(s);
            System.out.println("转换后：" + df.format(date));
            return;
        } catch (ParseException e) {
            System.out.println("匹配失败，进行下一次匹配！");
        }}
        System.out.println("日期格式非法");
    }
}
